<?php
namespace Blind\Controller;
use Think\Controller;
class AdminController extends Controller {

    public function index()
    {
        $res = M('admin') -> select();
        $this -> assign('data', $res);
        $this -> display();
    }

    public function add()
    {
        $this -> display('add');
    }

    public function doAdd()
    {
        $data = I('post.');
        $data['password'] = md5(I('post.password'));

        $res = M('admin') -> add($data);
        if($res)
        {
            $this -> success('成功', 'index');
        }else
        {
            $this -> error('失败');
        }
    }

    //删除
    public function adminDel($id)
    {
        $res = M('admin') -> where("id=%d",$id) -> delete();
        if($res)
        {
            $this -> success('成功');
        }else
        {
            $this -> error('失败');
        }
    }
}